<?php
class Admin_Form_SelectCategory extends Admin_Form_Select
{
  protected
    $choices;
  
  public function configure()
  {
    $filter = array_merge(array(
      'type' => 'post',
      'orderby' => 'name',
      'order' => 'ASC',
      'hide_empty' => false,
      'hierarchical' => 0,
      ), _parse_attributes(isset($this->options['filter']) ? $this->options['filter'] : null));
    
    $this->choices = array();
    foreach (get_categories($filter) as $cat)
    {
      $this->choices[$cat->term_id] = $cat->name;
    }
    
    unset($this->options['filter']);
  }
  
  public function __toString()
  {
    return select_tag($this->getName(), options_for_select((array) $this->choices, $this->value, $this->options), $this->html_options);
  }
}